
local mt = ac.skill['插飞你']
mt.targettype = '物体'
mt.range = 1200
mt.model1 = [[Abilities\Spells\Undead\Impale\ImpaleMissTarget.mdl]]

function mt:on_cast_shot()
    local hero = self.owner
    local target = self.target
    local point1 = hero:get_point()
    local point2 = target:get_point()
    local angle = point1/point2
    local damage = hero:get('攻击') * self.data1
    local lock = {}
    hero:add_restriction '硬直'
    
    hero:add_effect([[9753276ca38a709ee315c35f23214d61.mdl]],'chest',1)
    local effect = point1:effect{
        model = [[fdcd174428a0c65293cd271ce959629e.mdx]],
        angle = angle,
        height = 90,
    }
    local time = 0
    ac.loop(30,function(t)
        local point2 = target:get_point()
        local angle = point1/point2
        effect:set_facing(angle)
        time = time + 0.03
        if time>=1 or hero:is_alive()==false then
            t:remove()
            hero:remove_restriction '硬直'
            if hero:is_alive()==false then
                effect:remove()
                return
            end
            ac.mover('line'){
                start = point1,
                speed = 1200,
                angle = angle,
                distance = 1200,
                model = '',
                on_move = function(_,point)
                    point:add_effect(self.model1,1)
                    hero:aoe_damage(point,150,damage,self,function(unit)
                        if lock[unit.handle]==nil then
                            lock[unit.handle] = true
                            unit:add_buff '晕眩'{time=1}
                            unit:add_buff '击飞'{time=0.5}
                            return
                        end
                        return true
                    end)
                end,
                on_remove = function()
                    effect:remove()
                end
            }
        end
    end)

    
    
end
